package com.asset.dispoal.verdict;

import com.asset.dispoal.verdict.api.JudgmentBookService;
import com.asset.dispoal.verdict.dto.request.CreateOrEditRequest;
import com.asset.dispoal.verdict.dto.request.JudgmentBookRequest;
import com.asset.dispoal.verdict.dto.response.JudgmentBookResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @description: 判决书管理
 * @author: yf
 * @date: 2022-09-05
 */
@RestController
@Api(value = "判决书管理", tags = "判决书管理")
@RequestMapping("gb/verdict")
public class VerdictController {
    @Autowired
    private JudgmentBookService judgmentBookService;

    @Permission(code = "judgment:query", param = "create_user_id")
    @ApiOperation(value = "根据名称查询判决书")
    @PostMapping("/findJudgBook")
    public Result<PageVO<JudgmentBookResponse>> findEvidenceConf(@RequestBody JudgmentBookRequest request) {
        return judgmentBookService.findJudgmentBook(request);
    }

    @Deprecated
    @ApiOperation(value = "添加修改")
    @PostMapping("/insertOrUpdate")
    public Result insertOrUpdate(@RequestBody CreateOrEditRequest request) {
        return judgmentBookService.editOrCreate(request);
    }

    @Permission(code = "judgment:add")
    @ApiOperation(value = "添加")
    @PostMapping("/insert")
    public Result insert(@RequestBody CreateOrEditRequest request) {
        return judgmentBookService.editOrCreate(request);
    }

    @Permission(code = "judgment:update")
    @ApiOperation(value = "修改")
    @PostMapping("/update")
    public Result edit(@RequestBody CreateOrEditRequest request) {
        return judgmentBookService.editOrCreate(request);
    }

    @Permission(code = "judgment:del")
    @ApiOperation(value = "删除")
    @GetMapping("/del")
    public Result del(String judgmentId) {
        return judgmentBookService.deleteBookById(judgmentId);
    }

    @ApiOperation(value = "根据判决书id获取请求参数")
    @GetMapping("/getExtractParam")
    public Result getExtractParam(@ApiParam("判决书id") String bookId) {
        return judgmentBookService.getExtractParam(bookId);
    }
}
